package com.ruoyi.logCen.controller;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class test {


    public static void main(String[] args) {

        String logLine = "[2025-03-04 16:01:44,213] INF123O [GroupMetadataManager brokerId=150] Removed 0 expired offsets in 0 milliseconds. (kafka.coordinator.group.GroupMetadataManager)";

        // 定义正则表达式
        String regex = "^\\[(\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2},\\d{3})\\] (\\w+) (.*)$";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(logLine);

        // 匹配并提取内容
        if (matcher.find()) {
            String timestamp = matcher.group(1); // 时间
            String logLevel = matcher.group(2);  // 日志级别
            String logMessage = matcher.group(3); // 日志信息

            System.out.println("时间: " + timestamp);
            System.out.println("日志级别: " + logLevel);
            System.out.println("日志信息: " + logMessage);
        } else {
            System.out.println("未匹配到日志格式");
        }


    }
}
